//
// Created by hsj on 2022/3/10.
//

#include "t_multimap.h"
namespace t_multimap_test{
    //测试
    void test(){

        MapCode map_codes;
        map_codes.insert(Pair(415,"beijing"));
        map_codes.insert(Pair(411,"kunming"));
        map_codes.insert(Pair(412,"shenzhen"));
        map_codes.insert(Pair(418,"guangzhou"));
        map_codes.insert(Pair(415,"shenyang"));

        cout<<"how many 415:"<<map_codes.count(415)<<endl;
        //类对象上面获取迭代器，不是实例上面
        MapCode::iterator it;

        //获取415的条目
        pair<MapCode::iterator,MapCode::iterator>  range = map_codes.equal_range(415);
        for (it = range.first; it !=range.second ; ++it) {
            cout<<"  "<<it->second<<endl;
        }

        cout<<"alls of citys:"<<endl;
        //遍历multimap
        for (it = map_codes.begin(); it !=map_codes.end() ; ++it) {
            cout<<"  "<<it->first<<" : "<<it->second<<endl;
        }
    }
}